using System;
using System.Globalization;
using System.Linq;
using System.Windows;
using System.Windows.Data;

namespace Haidou.Wpf.Util.Converters;

public class BoolOrToVisibility : IMultiValueConverter
{
	public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
	{
		return values == null || values.Length == 0 || values.Any(a => a.GetType() != typeof(bool))
			? Visibility.Collapsed
			: (object)(values.Cast<bool>().Any(x => x) ? Visibility.Visible : Visibility.Collapsed);
	}

	public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
	{
		return null;
	}
}